package com.zmx.piglearn.service

import android.app.IntentService
import android.content.Intent
import android.os.IBinder
import android.util.Log

class TestIntentService(name: String? = "TestIntentService") : IntentService(name) {
    private val TAG = "### TestIntentService"

    override fun onHandleIntent(intent: Intent?) {
        val action = intent?.extras?.getString("param")
        Log.i(TAG, "启动 $action")
        try {
            Thread.sleep(2000)
        } catch (e: InterruptedException) {
            e.printStackTrace()
        }
    }

    override fun onBind(intent: Intent?): IBinder? {
        Log.i(TAG, "onBind()")
        return super.onBind(intent)
    }

    override fun onCreate() {
        Log.i(TAG, "onCreate()")
        super.onCreate()
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        Log.i(TAG, "onStartCommand()")
        return super.onStartCommand(intent, flags, startId)
    }

    override fun setIntentRedelivery(enabled: Boolean) {
        Log.i(TAG, "setIntentRedelivery()")
        super.setIntentRedelivery(enabled)
    }

    override fun onDestroy() {
        Log.i(TAG, "onDestroy()")
        super.onDestroy()
    }
}